{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "extensions": {
     "jupyter_dashboards": {
      "version": 1,
      "views": {
       "grid_default": {
        "hidden": true
       },
       "report_default": {}
      }
     }
    }
   },
   "outputs": [],
   "source": [
    "# Import mastml and get current working directory\n",
    "from mastml import mastml_driver\n",
    "import os\n",
    "cwd = os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "extensions": {
     "jupyter_dashboards": {
      "version": 1,
      "views": {
       "grid_default": {
        "hidden": true
       },
       "report_default": {}
      }
     }
    }
   },
   "outputs": [],
   "source": [
    "# Set paths for config file, data file and where to put output\n",
    "conf = os.path.join(cwd,'tests/conf/example_input.conf')\n",
    "csv = os.path.join(cwd,'tests/csv/example_data.csv')\n",
    "output = os.path.join(cwd,'results/example_results')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "extensions": {
     "jupyter_dashboards": {
      "version": 1,
      "views": {
       "grid_default": {
        "col": 0,
        "height": 12,
        "hidden": false,
        "row": 0,
        "width": 4
       },
       "report_default": {}
      }
     }
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[WARNING] /home/nanohub/rjacobs/results/example_results not empty. Renaming...\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[INFO] Saving to directory '/home/nanohub/rjacobs/results/example_results_04_23_09_53_43'\n",
      "[INFO] \n",
      "\n",
      "   __  ___     __________    __  _____\n",
      "  /  |/  /__ _/ __/_  __/___/  |/  / /\n",
      " / /|_/ / _ `/\\ \\  / / /___/ /|_/ / /__\n",
      "/_/  /_/\\_,_/___/ /_/     /_/  /_/____/\n",
      "\n",
      "\n",
      "MAST-ML run on 2019-04-23 13:53:43 using \n",
      "conf file: example_input.conf\n",
      "csv file:  example_data.csv\n",
      "saving to: example_results_04_23_09_53_43\n",
      "\n",
      "\n",
      "[INFO] \n",
      "\n",
      "   __  ___     __________    __  _____\n",
      "  /  |/  /__ _/ __/_  __/___/  |/  / /\n",
      " / /|_/ / _ `/\\ \\  / / /___/ /|_/ / /__\n",
      "/_/  /_/\\_,_/___/ /_/     /_/  /_/____/\n",
      "\n",
      "\n",
      "MAST-ML run on 2019-04-23 13:53:43 using \n",
      "conf file: example_input.conf\n",
      "csv file:  example_data.csv\n",
      "saving to: example_results_04_23_09_53_43\n",
      "\n",
      "\n",
      "[INFO] Copying input files to output directory...\n",
      "[INFO] Copying input files to output directory...\n",
      "[INFO] blacklisted features, either from \"not_input_features\" or a \"grouping_column\":['Host element', 'Solute element', 'predict_Pt']\n",
      "[INFO] blacklisted features, either from \"not_input_features\" or a \"grouping_column\":['Host element', 'Solute element', 'predict_Pt']\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[WARNING] You have chosen not to specify a method of data_cleaning in the input file. By default, any feature entries containing NaN will result in removal of the feature and any target data entries containing NaN will result in removal of that target data point.\n",
      "[WARNING] You have chosen not to specify a method of data_cleaning in the input file. By default, any feature entries containing NaN will result in removal of the feature and any target data entries containing NaN will result in removal of that target data point.\n",
      "[WARNING] Randomizer is enabled, so target feature will be shuffled, and results should be null for a given model\n",
      "[WARNING] Randomizer is enabled, so target feature will be shuffled, and results should be null for a given model\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[DEBUG] splitter_to_group_names:\n",
      "{}\n",
      "[DEBUG] splitter_to_group_names:\n",
      "{}\n",
      "[DEBUG] instantiation: KernelRidge, KernelRidge({'alpha': 0.009, 'gamma': 0.027, 'kernel': 'rbf'})\n",
      "[DEBUG] instantiation: KernelRidge, KernelRidge({'alpha': 0.009, 'gamma': 0.027, 'kernel': 'rbf'})\n",
      "[DEBUG] models, pre-snatching: \n",
      "OrderedDict([('KernelRidge', KernelRidge(alpha=0.009, coef0=1, degree=3, gamma=0.027, kernel='rbf',\n",
      "      kernel_params=None))])\n",
      "[DEBUG] models, pre-snatching: \n",
      "OrderedDict([('KernelRidge', KernelRidge(alpha=0.009, coef0=1, degree=3, gamma=0.027, kernel='rbf',\n",
      "      kernel_params=None))])\n",
      "[DEBUG] models, post-snatching: \n",
      "OrderedDict([('KernelRidge', KernelRidge(alpha=0.009, coef0=1, degree=3, gamma=0.027, kernel='rbf',\n",
      "      kernel_params=None))])\n",
      "[DEBUG] models, post-snatching: \n",
      "OrderedDict([('KernelRidge', KernelRidge(alpha=0.009, coef0=1, degree=3, gamma=0.027, kernel='rbf',\n",
      "      kernel_params=None))])\n",
      "[DEBUG] instantiation: DoNothing, DoNothing({})\n",
      "[DEBUG] instantiation: DoNothing, DoNothing({})\n",
      "[DEBUG] instantiation: StandardScaler, StandardScaler({})\n",
      "[DEBUG] instantiation: StandardScaler, StandardScaler({})\n",
      "[DEBUG] instantiation: RepeatedKFold_select, RepeatedKFold({'n_splits': 3, 'n_repeats': 2})\n",
      "[DEBUG] instantiation: RepeatedKFold_select, RepeatedKFold({'n_splits': 3, 'n_repeats': 2})\n",
      "[DEBUG] cv, pre-snatching: \n",
      "OrderedDict([('RepeatedKFold_select', <sklearn.model_selection._split.RepeatedKFold object at 0x7f58a95c6ef0>)])\n",
      "[DEBUG] cv, pre-snatching: \n",
      "OrderedDict([('RepeatedKFold_select', <sklearn.model_selection._split.RepeatedKFold object at 0x7f58a95c6ef0>)])\n",
      "[DEBUG] cv, post-snatching: \n",
      "OrderedDict([('RepeatedKFold_select', <sklearn.model_selection._split.RepeatedKFold object at 0x7f58a95c6ef0>)])\n",
      "[DEBUG] cv, post-snatching: \n",
      "OrderedDict([('RepeatedKFold_select', <sklearn.model_selection._split.RepeatedKFold object at 0x7f58a95c6ef0>)])\n",
      "[DEBUG] instantiation: DoNothing, DoNothing({})\n",
      "[DEBUG] instantiation: DoNothing, DoNothing({})\n",
      "[DEBUG] generators: \n",
      "[['DoNothing', NoGenerate()]]\n",
      "[DEBUG] generators: \n",
      "[['DoNothing', NoGenerate()]]\n",
      "[DEBUG] clusterers: \n",
      "[]\n",
      "[DEBUG] clusterers: \n",
      "[]\n",
      "[DEBUG] normalizers: \n",
      "[['StandardScaler', StandardScaler(copy=True, with_mean=True, with_std=True)]]\n",
      "[DEBUG] normalizers: \n",
      "[['StandardScaler', StandardScaler(copy=True, with_mean=True, with_std=True)]]\n",
      "[DEBUG] hyperopts: \n",
      "[]\n",
      "[DEBUG] hyperopts: \n",
      "[]\n",
      "[DEBUG] selectors: \n",
      "[['DoNothing', DoNothing()]]\n",
      "[DEBUG] selectors: \n",
      "[['DoNothing', DoNothing()]]\n",
      "[DEBUG] splitters: \n",
      "[('RepeatedKFold_select', <sklearn.model_selection._split.RepeatedKFold object at 0x7f58a95c6ef0>)]\n",
      "[DEBUG] splitters: \n",
      "[('RepeatedKFold_select', <sklearn.model_selection._split.RepeatedKFold object at 0x7f58a95c6ef0>)]\n",
      "[INFO] There are 1 feature normalizers, 0 hyperparameter optimziers, 1 feature selectors, 1 models, and 1 splitters.\n",
      "[INFO] There are 1 feature normalizers, 0 hyperparameter optimziers, 1 feature selectors, 1 models, and 1 splitters.\n",
      "[INFO] Doing feature generation...\n",
      "[INFO] Doing feature generation...\n",
      "[INFO] Saving generated data to csv...\n",
      "[INFO] Saving generated data to csv...\n",
      "[DEBUG] generated cols: Index([], dtype='object')\n",
      "[DEBUG] generated cols: Index([], dtype='object')\n",
      "[INFO] Removing constant features, regardless of feature selectors.\n",
      "[INFO] Removing constant features, regardless of feature selectors.\n",
      "[INFO] Saving generated data without constant columns to csv...\n",
      "[INFO] Saving generated data without constant columns to csv...\n",
      "[INFO] Doing clustering...\n",
      "[INFO] Doing clustering...\n",
      "[INFO] Saving clustered data to csv...\n",
      "[INFO] Saving clustered data to csv...\n",
      "[INFO] Running normalizer StandardScaler ...\n",
      "[INFO] Running normalizer StandardScaler ...\n",
      "[INFO] Saving normalized data to csv...\n",
      "[INFO] Saving normalized data to csv...\n",
      "[INFO] Running selectors...\n",
      "[INFO] Running selectors...\n",
      "[INFO]     Running selector DoNothing ...\n",
      "[INFO]     Running selector DoNothing ...\n",
      "[INFO]     Saving selected features to csv...\n",
      "[INFO]     Saving selected features to csv...\n",
      "[DEBUG] Finding splitter-required columns in data...\n",
      "[DEBUG] Finding splitter-required columns in data...\n",
      "[INFO] Fitting models to splits...\n",
      "[INFO] Fitting models to splits...\n",
      "[INFO]     Running splits for StandardScaler/DoNothing/KernelRidge/RepeatedKFold_select\n",
      "[INFO]     Running splits for StandardScaler/DoNothing/KernelRidge/RepeatedKFold_select\n",
      "[INFO]         Doing split number 0\n",
      "[INFO]         Doing split number 0\n",
      "[INFO]              Fitting model and making predictions...\n",
      "[INFO]              Fitting model and making predictions...\n",
      "[INFO]              Making predictions on prediction_only data...\n",
      "[INFO]              Making predictions on prediction_only data...\n",
      "[INFO]              Saving train/test data and predictions to csv...\n",
      "[INFO]              Saving train/test data and predictions to csv...\n",
      "[INFO]              Calculating score metrics...\n",
      "[INFO]              Calculating score metrics...\n",
      "[INFO]              Making plots...\n",
      "[INFO]              Making plots...\n",
      "[INFO]         Doing split number 1\n",
      "[INFO]         Doing split number 1\n",
      "[INFO]              Fitting model and making predictions...\n",
      "[INFO]              Fitting model and making predictions...\n",
      "[INFO]              Making predictions on prediction_only data...\n",
      "[INFO]              Making predictions on prediction_only data...\n",
      "[INFO]              Saving train/test data and predictions to csv...\n",
      "[INFO]              Saving train/test data and predictions to csv...\n",
      "[INFO]              Calculating score metrics...\n",
      "[INFO]              Calculating score metrics...\n",
      "[INFO]              Making plots...\n",
      "[INFO]              Making plots...\n",
      "[INFO]         Doing split number 2\n",
      "[INFO]         Doing split number 2\n",
      "[INFO]              Fitting model and making predictions...\n",
      "[INFO]              Fitting model and making predictions...\n",
      "[INFO]              Making predictions on prediction_only data...\n",
      "[INFO]              Making predictions on prediction_only data...\n",
      "[INFO]              Saving train/test data and predictions to csv...\n",
      "[INFO]              Saving train/test data and predictions to csv...\n",
      "[INFO]              Calculating score metrics...\n",
      "[INFO]              Calculating score metrics...\n",
      "[INFO]              Making plots...\n",
      "[INFO]              Making plots...\n",
      "[INFO]         Doing split number 3\n",
      "[INFO]         Doing split number 3\n",
      "[INFO]              Fitting model and making predictions...\n",
      "[INFO]              Fitting model and making predictions...\n",
      "[INFO]              Making predictions on prediction_only data...\n",
      "[INFO]              Making predictions on prediction_only data...\n",
      "[INFO]              Saving train/test data and predictions to csv...\n",
      "[INFO]              Saving train/test data and predictions to csv...\n",
      "[INFO]              Calculating score metrics...\n",
      "[INFO]              Calculating score metrics...\n",
      "[INFO]              Making plots...\n",
      "[INFO]              Making plots...\n",
      "[INFO]         Doing split number 4\n",
      "[INFO]         Doing split number 4\n",
      "[INFO]              Fitting model and making predictions...\n",
      "[INFO]              Fitting model and making predictions...\n",
      "[INFO]              Making predictions on prediction_only data...\n",
      "[INFO]              Making predictions on prediction_only data...\n",
      "[INFO]              Saving train/test data and predictions to csv...\n",
      "[INFO]              Saving train/test data and predictions to csv...\n",
      "[INFO]              Calculating score metrics...\n",
      "[INFO]              Calculating score metrics...\n",
      "[INFO]              Making plots...\n",
      "[INFO]              Making plots...\n",
      "[INFO]         Doing split number 5\n",
      "[INFO]         Doing split number 5\n",
      "[INFO]              Fitting model and making predictions...\n",
      "[INFO]              Fitting model and making predictions...\n",
      "[INFO]              Making predictions on prediction_only data...\n",
      "[INFO]              Making predictions on prediction_only data...\n",
      "[INFO]              Saving train/test data and predictions to csv...\n",
      "[INFO]              Saving train/test data and predictions to csv...\n",
      "[INFO]              Calculating score metrics...\n",
      "[INFO]              Calculating score metrics...\n",
      "[INFO]              Making plots...\n",
      "[INFO]              Making plots...\n",
      "[INFO]     Calculating mean and stdev of scores...\n",
      "[INFO]     Calculating mean and stdev of scores...\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[INFO]     Making best/worst plots...\n",
      "[INFO]     Making best/worst plots...\n",
      "[INFO] Making image html file...\n",
      "[INFO] Making image html file...\n",
      "[INFO] wrote /home/nanohub/rjacobs/results/example_results_04_23_09_53_43/index.html\n",
      "[INFO] wrote /home/nanohub/rjacobs/results/example_results_04_23_09_53_43/index.html\n",
      "[INFO] Making html file of all runs stats...\n",
      "[INFO] Making html file of all runs stats...\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'/home/nanohub/rjacobs/results/example_results_04_23_09_53_43'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Start MASTML session\n",
    "mastml_driver.main(conf, csv, output)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true,
    "extensions": {
     "jupyter_dashboards": {
      "version": 1,
      "views": {
       "grid_default": {
        "hidden": true
       },
       "report_default": {}
      }
     }
    }
   },
   "outputs": [],
   "source": [
    "# Done!"
   ]
  }
 ],
 "metadata": {
  "extensions": {
   "jupyter_dashboards": {
    "activeView": "grid_default",
    "version": 1,
    "views": {
     "grid_default": {
      "cellMargin": 10,
      "defaultCellHeight": 20,
      "maxColumns": 12,
      "name": "grid",
      "type": "grid"
     },
     "report_default": {
      "name": "report",
      "type": "report"
     }
    }
   }
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "tool": false
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
